#include <iostream>
#include <vector>
#include <unistd.h>

#ifdef _WIN32
#define popen _popen
#endif

using namespace std;
int main(int argc, char const *argv[])
{
    auto fp = popen("ping www.baidu.com", "r");
    if (fp == 0)
    {
        return -1;
    }

    string temp;
    char c;
    while (c = fgetc(fp))
    {
        if (c == EOF)
        {
            break;
        }
        if (c == '\n')
        {
            cout << temp << endl;
            temp = "";
            continue;
        };

        temp += c;
    }

    return 0;
}
